#include <stdio.h>
#include <stdlib.h>
#include "Structs.h"
#include "Pong3D.h"
#include <GL/glut.h>
#include <math.h>
#include <Windows.h>



void copyArray(GLfloat *a, GLfloat *b, int size){
	int i = 0;
	for (;i < size; i++){
		a[i] = b[i];
	}
}

GLuint raw_texture_load(const char *filename, int width, int height)
{
	GLuint texture;
	GLbyte *data;
	GLint iWidth, iHeight, iComponent;
	GLenum eFormat;

	// allocate buffer
	data = gltLoadTGA(filename, &iWidth, &iHeight, &iComponent, &eFormat);
	gluBuild2DMipmaps(GL_TEXTURE_2D, iComponent, iWidth, iHeight, eFormat, GL_UNSIGNED_BYTE, data);



	// allocate a texture name
	glGenTextures(1, &texture);

	// select our current texture
	glBindTexture(GL_TEXTURE_2D, texture);

	// select modulate to mix texture with color for shading
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

	// texture should tile
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	free(data);
	return texture;
}